﻿#region License statement
// NJamb, a specification and delta-specification DSL
// Copyright (c) 2010-2011, Mark Knell
// Published under the MIT License; all other rights reserved
#endregion

#region using...
using System.Collections.Generic;
using NJamb.Specifications.Simple.Enumerable;
using Stile.Patterns.SelfDescribingPredicates;
using Stile.Patterns.SelfDescribingPredicates.Evaluators;
#endregion

namespace NJamb.Parser.SpecificationBuilders.SubjectIs.Simple.Enumerable
{
    public static class EnumerableIsExtensions
    {
        public static IEnumerableSpecification<TSubject, TItem> ReadOnly<TSubject, TItem>(
            this ISimpleEnumerableIs<TSubject, TItem> collaboratingIs) where TSubject : class, ICollection<TItem>
        {
            Evaluator<TSubject, bool> evaluator =
                ExpectEnumerable<TSubject, TItem>.ToBeReadOnly<TSubject>(collaboratingIs.Xray.Negated);
            IEnumerableSpecification<TSubject, TItem> specifies = collaboratingIs.Xray.SpecificationBuilder.Specify(evaluator);
            return specifies;
        }

        public static IEnumerableSpecification<TSubject, TItem> ReadOnly<TSubject, TItem>(
            this INegatableEnumerableIs<TSubject, TItem> collaboratingIs) where TSubject : class, ICollection<TItem>
        {
            Evaluator<TSubject, bool> evaluator =
                ExpectEnumerable<TSubject, TItem>.ToBeReadOnly<TSubject>(collaboratingIs.Xray.Negated);
            IEnumerableSpecification<TSubject, TItem> specifies = collaboratingIs.Xray.SpecificationBuilder.Specify(evaluator);
            return specifies;
        }
    }
}
